﻿
using Knlght.Domain;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Knight.Models.Entity
{
    /// <summary>
    /// 友情链接
    /// </summary>
    public class LinkInfo: TEntityBase
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string JumpLink { get; set; }
        public string ImageUrl { get; set; }
        public int ImageWidth { get; set; }
        public int ImageHeight { get; set; }
        public bool IsBlank { get; set; }
        public bool IsEnabled { get; set; }
        public int DisplayIndex { get; set; }
        public DateTime AddTime { get; set; }

    }

    public class LinkInfoMapping : EntityTypeConfiguration<LinkInfo>
    {
        public LinkInfoMapping()
        {
            // 设置表名
            this.ToTable("T" + nameof(LinkInfo));
            //设置主键
            this.HasKey(a => a.Id);
            //不自增
            //this.Property(t => t.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            //不更新
            this.Property(t => t.AddTime).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);
            // 设置属性的类型和长度
            this.Property(a => a.Name).HasColumnType("NVarchar").HasMaxLength(200);
        }
    }
}
